## Process this file with automake to produce Makefile.in
# Copyright (C) 2000-2012 Free Software Foundation, Inc.
# Copyright (C) 2020, 2021 Maxime Devos
#
# Author (GnuTLS): Nikos Mavrogiannopoulos
# Author (scheme-GNUnet): Maxime Devos
#
# This file was part of scheme-GNUnet.
#
# scheme-GNUnet is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or (at
# your option) any later version.
#
# scheme-GNUnet is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with scheme-GNUnet.  If not, see <http://www.gnu.org/licenses/>.

# This file is partially based upon guile/Makefile.am in GnuTLS.
# Not all scheme-GNUnet code is licensed as GPL, some is licensed as AGPL.

ACLOCAL_AMFLAGS = -I m4
AM_CPPFLAGS = -I$(top_srcdir)/include
SUFFIXES = .scm .go

# Scheme code that works
modules = \
  gnu/gnunet/scripts/download-store.scm \
  gnu/gnunet/scripts/publish-store.scm \
  gnu/gnunet/scripts/guix-stuff.scm \
  \
  gnu/gnunet/message/protocols.scm \
  \
  gnu/gnunet/concurrency/update.scm \
  gnu/gnunet/concurrency/repeated-condition.scm \
  \
  gnu/gnunet/mq/envelope.scm \
  gnu/gnunet/mq/handler.scm \
  gnu/gnunet/mq/prio-prefs.scm \
  gnu/gnunet/mq/prio-prefs2.scm \
  gnu/gnunet/mq.scm \
  \
  gnu/gnunet/mq-impl/stream.scm \
  \
  gnu/gnunet/utils/bv-slice.scm \
  gnu/gnunet/utils/hat-let.scm \
  gnu/gnunet/utils/netstruct.scm \
  gnu/gnunet/utils/platform-enum.scm \
  gnu/gnunet/utils/tokeniser.scm \
  \
  gnu/gnunet/config/parser.scm \
  gnu/gnunet/config/value-parser.scm \
  gnu/gnunet/config/expand.scm \
  gnu/gnunet/config/db.scm \
  \
  gnu/gnunet/util/cmsg.scm \
  gnu/gnunet/icmp/struct.scm \
  \
  gnu/gnunet/util/struct.scm \
  gnu/gnunet/crypto/struct.scm \
  gnu/gnunet/hashcode/struct.scm \
  gnu/gnunet/nse/struct.scm \
  \
  gnu/gnunet/netstruct/procedural.scm \
  gnu/gnunet/netstruct/syntactic.scm

dist_guilesite_DATA = $(modules)

# Scheme code compilation
if HAVE_GUILD
nodist_guilesiteccache_DATA = $(modules:%.scm=%.go)

# Do not unset 'GUILE_LOAD_COMPILED_PATH', as guile-pfds as installed
# in Guix does not have .scm files (but it does in Guile).
# XXX: Use the C locale for when Guile lacks
# <https://git.sv.gnu.org/cgit/guile.git/commit/?h=stable-2.0&id=e2c6bf3866d1186c60bacfbd4fe5037087ee5e3f>.
%.go: %.scm
	$(AM_V_GUILEC)$(MKDIR_P) "`dirname "$@"`" ;			\
	$(AM_V_P) && out=1 || out=- ;					\
	LC_ALL=C							\
	builddir="$(top_builddir)"					\
	GUILE_AUTO_COMPILE=0						\
	$(GUILD) compile --target="$(host)"				\
	  -L "$(top_srcdir)"						\
	  -Wformat -Wunbound-variable -Warity-mismatch			\
	  -o "$@" "$<" >&$$out
endif

TEST_EXTENSIONS = .scm
TESTS =

# Scheme tests
# FIXME ./pre-inst-env & ./test-env
SCM_LOG_DRIVER = \
  $(GUILE) -L $(top_srcdir) -C $(top_builddir) \
    -e main $(top_srcdir)/build-aux/test-driver.scm

SCM_TESTS = \
  tests/envelope.scm \
  tests/message-handler.scm \
  tests/mq.scm \
  tests/mq-stream.scm \
  tests/update.scm \
  tests/repeated-condition.scm \
  tests/bv-slice.scm \
  tests/cmsg.scm \
  tests/config-parser.scm \
  tests/config-value-parser.scm \
  tests/config-expander.scm \
  tests/config-db.scm \
  tests/netstruct.scm \
  tests/tokeniser.scm

SCM_TESTS_ENVIRONMENT = \
  GUILE_AUTO_COMPILE=0 \
  GUILE_WARN_DEPRECATED=detailed
TESTS += $(SCM_TESTS)
